home *** CD-ROM | disk | FTP | other *** search
/ 45 Great Windows Utilities 6 / 45 Great Windows Utilities Volume 6 MOJO-405 (Mojo Software).iso / martin / fract.txt < prev    next >
Text File  |  1993-02-28  |  1KB  |  64 lines

  1. Here is the heart of the Martin fractal code for those interested
  2.  
  3. //------------------------------------------------------------------
  4. // InitSaver()
  5. //------------------------------------------------------------------
  6.  
  7. void InitSaver(HWND hWnd)
  8. {
  9.     a = double(random(100) - 50);
  10.     b = double(random(100) - 50);
  11.     c = double(random(100) - 50);
  12.     s = (abs(a) + abs(b) + abs(c)) / 3.0;
  13.     s = 6.0 - (abs(s/10.0));
  14.  
  15.     ClearScreen(hWnd);
  16.  
  17.     tc = 0;
  18.     xold = 0.0;
  19.     yold = 0.0;
  20.  
  21. };
  22.  
  23.  
  24. //------------------------------------------------------------------
  25. // Martin()
  26. //------------------------------------------------------------------
  27.  
  28. void Martin(HWND hWnd)
  29. {
  30.   static int t   = 0;
  31.   static int clr = random(NumColor);
  32.  
  33.   double xnew, ynew ;
  34.  
  35.   if (t > tMax)
  36.   {
  37.     tc++;
  38.     t = 0;
  39.     clr = (clr+1) % NumColor;
  40.   };
  41.  
  42.   Plot(hWnd, xold*s, yold*s, clr);
  43.  
  44.   xnew = yold - Sign(xold)*sqrt(abs(b*xold-c));
  45.   ynew = a - xold;
  46.   xold = xnew ;
  47.   yold = ynew ;
  48.  
  49.   t++;
  50.  
  51. }
  52.  
  53. //------------------------------------------------------------------
  54. // SaverStep()
  55. //------------------------------------------------------------------
  56.  
  57. void SaverStep(HWND hWnd)
  58. {
  59.   if (tc > tcMax) InitSaver(hWnd);
  60.  
  61.   Martin(hWnd);
  62. };
  63.  
  64.